﻿// 全局状态
$(function () {
    const connection = new signalR.HubConnectionBuilder().withUrl("/clock").build();
    //connection.on("disconnected", message => { console.log(message); show(message); });
    connection.on("notify", message => { console.log(message); show(message); });
    connection.onclose(function () { show("服务连接已经断开,请刷新页面."); });
    //connection.invoke("ReadState").cache(err => console.error(err.toString()));
    connection.start().catch(err => { console.log(err); show(err.message); });
});
function show(message) {
    $("#msglist").append($("<li></li>").text(message));
}